import json
from flask import Flask, request, Response
import json
import numpy as np
import time
import cv2

app = Flask(__name__)

@app.route('/', methods=['POST'])
def get_frame():
    start_time = time.time()
    res = json.loads(request.data)
    frame = eval(res["image"].decode("base64"))   # dtype为int32
    frame = np.array(frame, dtype=np.uint8)
    cv2.imwrite('/home/tmp.jpg',frame)
    duration = time.time() - start_time
    print('duration:[%.0fms]' % (duration*1000))
    return '0000'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)